package com.wx.service.impl;

import com.wx.dao.PatientDao;
import com.wx.dao.impl.PatientDaoImpl;
import com.wx.domain.Patient;
import com.wx.service.PatientService;

import java.util.HashMap;
import java.util.Map;

public class PatientServiceImpl implements PatientService {
    public PatientDao patientDao=new PatientDaoImpl();
    @Override
    public Patient findByUsername(String username) {
        return patientDao.findByUsername(username);
    }

    @Override
    public void modifyPassword(String username, String password) {
        patientDao.modifyPassword(username,password);
    }

    @Override
    public double getWalletById(String patientId) {
        return patientDao.getWalletById(patientId);
    }

    @Override
    public Map<String, Object> addpatient(Patient patient) {
        Patient findUsername = patientDao.findByUsername(patient.getUsername());
        Map<String,Object> map =new HashMap<>();
        if (findUsername!=null){
            map.put("isTrue",false);
            map.put("msg","该用户已存在！");
            return map;
        }else{
            int id= patientDao.add(patient);
            map.put("id",id);
            map.put("isTrue",true);
            map.put("msg","注册成功！");
            for (String s : map.keySet()) {
                System.out.println(s+map.get(s));
            }
            return map;
        }



    }
}
